Returns or sets a value indicating how a parameter is passed to or from a procedure.
Syntax
object.Direction [= value]
The Direction property syntax has these parts:
Part | Description |
object | An object expression that evaluates to an object in the Applies To list. |
value | A constant or Integer as described in Settings. |
Settings
The settings for value are one of the following values:
Constant | Value | Description |
rdParamInput | 0 | (Default) The parameter is used to pass information to the procedure. |
rdParamInputOutput | 1 | The parameter is used to pass information both to and from the procedure. |
rdParamOutput | 2 | The parameter is used to return information from the procedure as in an output parameter in SQL. |
rdParamReturnValue | 3 | The parameter is used to return the return status value from a procedure. |
Remarks
When working with stored procedures, and parameter queries you should identify those parameters that are to be managed by RDO on your behalf — but only when using drivers that do not automatically detect parameter direction. A parameterized query can take virtually any number of input arguments — each of these need to be marked when you create your query.
Generally, your query returns a set of rows that meet the requirements established in the query based on the parameters you provide at runtime. However, when working with stored procedures, another aspect is exposed. Stored procedures return information using row sets, return status, and output parameters. Because of this, each parameter returned by your stored procedure must be marked when creating your query.
The Direction property determines whether the parameter is an input parameter, output parameter, or both — or if the parameter is the return value from the procedure.
Note When first addressing the rdoParameter object to set the Direction property you might trip a trappable error if the rdoParameters collection could not be created. Generally this is due to syntax errors in the query or other problems that prevented RDO from creating the collection.
Some ODBC drivers do not provide information on the direction of parameters to a SELECT statement or procedure call so all parameter directions default to rdParamInput. In these cases, it is necessary to set the direction in code prior to executing the query.
Note The Microsoft SQL Server 6.x driver automatically sets the Direction property for all procedure parameters so you should not have to set the Direction property for any of your queries' parameters.
The Direction property is associated with the rdoParameter object but it is generally unnecessary to address the rdoParameter object itself as it is the default collection of the rdoQuery object as shown in the examples below.
For example, the following procedure returns a value from a stored procedure:
{? = call sp_test}
This call produces one parameter — the return value. It is necessary to set the direction of this parameter to rdParamOutput or rdParamReturnValue before executing the prepared statement. For example:
Dim my_statement As rdoQuery
Set my_statement = someRdoConnection.CreateQuery _
("MyPs", "{? = call sp_testprocedure }", ...)
my_statement.rdoParameters(0).Direction = _
rdParamReturnValue
my_statement.Execute
Print my_statement.rdoParameters(0)
You need to set all parameter directions except rdParamInput before accessing or setting the values of the parameters and before executing the rdoQuery.
You should use rdParamReturnValue for return values, but you can use rdParamOutput where rdParamReturnValue is not supported.